﻿@{
    Layout = null;
}
<script src="@Url.Content("~/Scripts/jquery-1.8.2.js")"></script>
<script src="@Url.Content("~/Scripts/jquery-ui-1.9.1.js")"></script>
<script src="@Url.Content("~/Scripts/jquery-ui-timepicker-addon.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Content/js/jsToastMessage/javascript/jquery.toastmessage.js")"></script>        <!-- end page-heading -->
        <div id="addtiendo-main" class="block">
            @if (ViewBag.MaDeTai != null)
            {
                
                <input type="hidden" style="width:100%;" id="maDeTai" value="@ViewBag.MaDeTai" />
            }
            else{
                
                <input type="hidden" style="width:100%;" id="maDeTai" value="" />
            }
            <table>
                <tr>
                    <th>Tiêu đề(*):</th>
                    <td><input type="text" id="tieuDeTienDo" /></td>                    
                </tr>
                <tr>
                    <th>Nội dung(*):</th>
                    <td><textarea cols="36" rows="7" id="noiDungTienDo"></textarea></td>
                </tr>
                <tr>
                    <th>Tiến độ hoàn thành(*) (%):</th>
                    <td><input type="text" style="width:100%;" id="tienDoHoanThanh" /></td>
                </tr>
            </table>
            <div><input type="hidden" id="btnaddtiendodetai" /></div>
        </div>


<div class="clear">&nbsp;</div>
<script>
    $(document).ready(function () {
        $("#btnaddtiendodetai").click(function () {        
            var madetai=$("#maDeTai").val();
            var tieude = $("#tieuDeTienDo").val();
            var noidung = $("#noiDungTienDo").val();
            var tiendohoanthanh = $("#tienDoHoanThanh").val();
            if (isNumeric(tiendohoanthanh)) {
                $.post("/GiangVienClient/AddTienDoDeTai", { maDeTai: madetai, tieuDe: tieude, noiDung: noidung, tienDoHoanThanh: tiendohoanthanh }, function (data) {
                    if (data.success == true) {
                        $("#quanlytiendo-main").load("/giangvienclient/tiendodetai/" + madetai);
                        $("#tieuDeTienDo").val("");
                        $("#noiDungTienDo").val("");
                        $("#tienDoHoanThanh").val("");
                        ThongBao(data);
                        $(this).close();
                    }
                    else {
                        ThongBao(data);
                    }
                    //alert(data.message);
                });
            }
            else {
                ToastManager.showStickyWarningToast("Tiến độ phải là một số >0");
            }
        });
    });
    function isNumeric(string) {
        var numericExpression = /^[0-9]+$/;
        if (string.match(numericExpression)) {
            return true;
        } else {
            return false;
        }
    }
    function ThongBao(data) {
        if (data.success)
            ToastManager.showSuccessToast("Cập nhật thành công.");
        else {
            ToastManager.showStickyWarningToast(data.message);
        }
    }
</script>